package com.sx.zongzhi.adapter;


import android.content.Context;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.LinearLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sx.zongzhi.R;
import com.sx.zongzhi.bean.KeyPunishBean;

import java.util.List;

/**
 * Created by XZY on 2017/11/23.
 * 重点地区排查整治
 */

public class KeyPunishAdapter extends BaseQuickAdapter<KeyPunishBean.RowsBean,BaseViewHolder> {

    private Context context;

    public KeyPunishAdapter(Context context, @LayoutRes int layoutResId,
                            @Nullable List<KeyPunishBean.RowsBean> data) {
        super(layoutResId, data);
        this.context=context;
    }

    @Override
    protected void convert(BaseViewHolder helper, final KeyPunishBean.RowsBean item) {
        helper.setText(R.id.tv_Name,item.getCreateUser());
        helper.setText(R.id.tv_Time,item.getCreateDate());
        helper.setText(R.id.tv_Title,item.getSecurityProblems()!=null?
                item.getSecurityProblems().getDisplayName():"");
        helper.setText(R.id.tv_Type,item.getInvolvedType()!=null?
                item.getInvolvedType().getDisplayName():"");
        helper.setText(R.id.tv_Address,item.getSecurityKeyAreas());
        RecyclerView recyclerView=helper.getView(R.id.recyclerView);
       if (item.getFiles()!=null&&item.getFiles().size()>0){
           recyclerView.setVisibility(View.VISIBLE);
           recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayout.HORIZONTAL, false));
           PictureAdapter pictureAdapter = new PictureAdapter(context, item.getFiles());
           recyclerView.setAdapter(pictureAdapter);
       }else {
           recyclerView.setVisibility(View.GONE);
       }
    }

}
